﻿using System;
using System.Windows.Forms;
using Omega.Game.Framework;
using SharpDX;
using SharpDX.Direct3D9;
using SharpDX.Windows;
using Omega.Game.Framework.Interfaces;

namespace Omega.Game.Framework
{

    public class DirectXEngine : IDirecXEngine
    {

        
       
       
        public virtual void StartLoop()
        {
            Graphics.CreateGameLoop(Update);
        }

        public virtual void CreateRender(IntPtr _handle)
        {
            Graphics.Initialize(_handle);
            Graphics.SetRenderMethod(Draw);
        }
        public void Draw()
        {

        }
        public virtual void Draw(Device device)
        {

            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, (Color4)Colors.DarkGray, 0.0f, 1);
            device.BeginScene();




            
            device.EndScene();
            device.Present();

        }


        public virtual void Dispose()
        {

        }

        public virtual void Update()
        {
            Draw(Graphics.device);
        }


        public virtual void StartLoop(Action CallBack)
        {
            Graphics.CreateGameLoop(CallBack);
        }

        public void CreateRender()
        {
            CreateRender(IntPtr.Zero);
        }


        public void StartLoop(Form form, Action CallBack)
        {
            Init();
            Graphics.CreateGameLoop(form, CallBack);
        }
        public void StartLoop(Form form)
        {
            Init();
            Graphics.CreateGameLoop(form, Update);

        }


        public bool NeedDraw
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public bool Disposed
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public void Init()
        {
            


        }

        public string Name
        {
            get;
            set;
        }

        public string Version
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public IComponent Parent
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }
    }
}
